﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using OreSystem.Entities;
using OreSystem.DAL;
namespace OreSystem.BLL
{    
    public class CarBLL
    {
        private CarDAL carDAL = new CarDAL();
        public IList<Car> GetAll()
        {
            return carDAL.GetAll();
        }

        public void Save(Car NewCar)
        {
            carDAL.Save(NewCar);
        }

        public Car GetCarById(int id)
        {
            return carDAL.GetCarById(id);
        }
       

        public void DeleteCar(Car car)
        {
            carDAL.DeleteCar(car);
        }

        public IList<Car> GetCarByType(int p)
        {
            return carDAL.GetCarByType(p);
        }

        public IList<Car> GetCarByType(int type, string keys) {
            return carDAL.GetCarByTypeAndKeys(type,keys);
        }


        public IList<Car> GetListByKey(string keys, int type) {
            return carDAL.GetCarByTypeAndKeys(type,keys);
        }

        public IList<Car> GetListByPage(int type,int page, int rows)
        {
            return carDAL.GetCarByType(type).Skip(page*rows).Take(rows).ToList();
        }

        public void Deletes(IList<object> idlist)
        {
            carDAL.Deletes(idlist);
        }

        public IList<Car> GetListByKey(string q, int type, out int total)
        {
            var cars = carDAL.GetCarByTypeAndKeys(type, q);
            total = cars.Count;
            return cars;
        }
    }
}
